﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iLangl.Transport.Communication;

namespace iLangl.Plugin
{
	public class PluginPackageManager: BasePackageManager, IPluginPackageManager
	{
		public PluginPackageManager(IAuthenticationService service)
		{
			Service = service;
		}

		public override IPackage CreateNewPackage()
		{
			IPackage package = base.CreateNewPackage();
			IConfigurationManager manager = ConfigurationFactory.Instance.CreateConfigurationManager();

			IPluginConfiguration pc = manager.GetPluginConfiguration(manager.SiteId);

			if (Service != null)
				package.SessionId = Service.Authenticate(pc.SiteId);

			package.PluginLiceneKey = pc.PluginLicenseKey;

			return package;
		}

		#region IPluginPackageManager Members

		public IAuthenticationService Service
		{
			get;
			set;
		}

		#endregion
	}
}
